import { codo } from "egg";
import CodoBase from "../lib/CodoBase";
import WeWorkService from "../lib/wework";

export default class WeWork extends CodoBase {
	getWeWorkServiceInstance(config: codo.WeWork.IWeWorkConfig) {
		return new WeWorkService(config, this.app);
	}

	/** 获取企业app服务实例，针对企业自建应用 */
	getWeWorkServiceCorpInstance(config: codo.WeWork.IWeWorkConfig) {
		return new WeWorkService(config, this.app);
	}

	/** 获取服务商app服务实例，针对服务商 */
	getWeWorkServiceProviderInstance(corpId: string, providerSecret: string) {
		const config = {
			appId: corpId,
			secret: providerSecret,
			agentId: 0,
		};
		return new WeWorkService(config, this.app);
	}

	/** 获取第三方应用app服务实例，针对第三方应用 */
	getWeWorkServiceSuiteInstance(suiteId: string, suiteSecret: string) {
		const config = {
			appId: suiteId,
			secret: suiteSecret,
			agentId: 0,
		};
		return new WeWorkService(config, this.app);
	}
}
